//
//  HotInformationCell.m
//  MoXiProject
//
//  Created by 沈晨宇 on 2017/7/18.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "HotInformationCell.h"

@implementation HotInformationCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.newsImage=[UIImageView new];
        //                self.newsImage.backgroundColor=[UIColor redColor];
        [self.contentView addSubview:self.newsImage];
        
        self.title=[UILabel new];
        self.title.textColor=baseBlackColor;
        self.title.font=DEF_MyFont(14);
        self.title.numberOfLines=0;
        self.title.textAlignment=NSTextAlignmentLeft;
        [self.contentView addSubview:self.title];
        
        
        
        self.ReleasePeople=[UILabel new];
        self.ReleasePeople.textColor=DEF_COLOR_MAINCOLOR;
        self.ReleasePeople.font=DEF_MyFont(12);
        self.ReleasePeople.textAlignment=NSTextAlignmentLeft;
        [self.contentView addSubview:self.ReleasePeople];
        
        self.date=[UILabel new];
        self.date.textColor=baseLightBlackColor;
        //        self.date.backgroundColor=[UIColor redColor];
        self.date.font=DEF_MyFont(12);
        self.date.textAlignment=NSTextAlignmentLeft;
        [self.contentView addSubview:self.date];
        
        self.readNum=[UILabel new];
        self.readNum.textColor=baseLightBlackColor;
        //        self.readNum.backgroundColor=[UIColor redColor];
        self.readNum.font=DEF_MyFont(12);
        self.readNum.textAlignment=NSTextAlignmentRight;
        [self.contentView addSubview:self.readNum];
        
        self.line=[UIView new];
        self.line.backgroundColor=DEF_COLOR_F0F0F0;
        [self.contentView addSubview:self.line];
        
        
    }
    
    return self;
}

-(void)setModel:(HotInformationModel *)model{
    _model=model;
    [self setFrame];
    [self setData];
    
}

-(void)setFrame{
    
    [self.newsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(60);
        make.top.equalTo(self.contentView).with.offset(12);
        make.trailing.equalTo(self.contentView).with.offset(-10);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH);
        make.height.mas_equalTo(1);
        make.top.equalTo(self.newsImage.mas_bottom).with.offset(12);
        make.leading.equalTo(self.contentView).with.offset(0);
    }];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(DEF_DEVICE_WIDTH-80-20-5);
        make.height.mas_equalTo(35);
        make.top.equalTo(self.contentView).with.offset(12);
        make.leading.equalTo(self.contentView).with.offset(10);
    }];
    
    [self.ReleasePeople mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(14);
        make.leading.equalTo(self.contentView).with.offset(10);
        make.bottom.equalTo(self.line).with.offset(-12);
    }];
    
    [self.date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(14);
        make.centerY.equalTo(self.ReleasePeople);
        make.leading.equalTo(self.ReleasePeople.mas_trailing).with.offset(5);
    }];
    
    [self.readNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(85);
        make.height.mas_equalTo(14);
        make.centerY.equalTo(self.ReleasePeople);
        make.trailing.equalTo(self.newsImage.mas_leading).with.offset(-10);
    }];
    

    
    self.frame=CGRectMake(0, 0, 0, 85);
    
}
-(void)setData{
    
    NSRange range = NSMakeRange(5,11);
    NSString* dateStr= [_model.noticeregistertime substringWithRange:range];
    self.title.text=_model.noticetitle;
    self.ReleasePeople.text=@"热门";
    self.date.text=dateStr;
    self.readNum.text=[NSString stringWithFormat:@"阅读%@",_model.noticereadCount];
    [self.newsImage sd_setImageWithURL:[NSURL URLWithString:_model.noticeimageurl]placeholderImage:DEF_NORMAL_DEFAULT_IMAGE];
    
}


@end
